package com.msf.infra.service.server.controller;

import com.netflix.discovery.shared.Application;
import com.netflix.discovery.shared.Applications;
import com.netflix.eureka.registry.InstanceRegistry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 服务注册控制器
 * <p>
 * 服务租约：LeaseManager
 *
 * @author zhiwei_yang
 * @time 2020-3-17-15:36
 */
@RestController
@RequestMapping("/registry")
public class RegistryController {

    @Autowired
    private InstanceRegistry instanceRegistry;

    /**
     * 获取注册中心服务实例信息
     *
     * @return
     */
    @GetMapping("/getRegistryInfo")
    public List<Application> getRegistryInfo() {
        Applications applications = instanceRegistry.getApplications();
        return applications.getRegisteredApplications();
    }
}